import cv2

# 读取车牌背景
panel_back = cv2.imread("./img/panels/back/blue_140.PNG")
# 设置图像的大小
panel_back = cv2.resize(panel_back, (440, 140))
# 读取车牌文字
panel_city = cv2.imread("./img/panels/test/140_test.jpg")
# 获取文字的宽高比例
h, w, _ = panel_city.shape
scale = w / h
# 改变车牌首写城市字的大小
panel_city = cv2.resize(panel_city, (int(scale * 100), 100))
# 将城市字设置为黑底白色
panel_city = 255 - panel_city
# 重新获取字体大小的值
h, w = int(scale * 100), 100
# 从车牌的区域抠出一块区域给城市字体
part1 = panel_back[20:w + 20, 20:h + 20]
# 将上述的区域与城市字体进行“图像融合”
result = cv2.bitwise_or(part1, panel_city)
# 将融合区域再次赋值给整个车牌
panel_back[20:w + 20, 20:h + 20] = result
# 查看图像大小
cv2.imshow("panel_back", panel_back)
cv2.waitKey(0)
